package com.brillilab.service.core.kit.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.brillilab.dao.mapper.kit.ReagentPlasmidFragmentMapper;
import com.brillilab.domain.po.kit.ReagentPlasmidFragment;
import com.brillilab.domain.po.kit.ReagentPrimerAttr;
import com.brillilab.service.core.kit.IReagentPlasmidFragmentService;

@Service
@Transactional
public class ReagentPlasmidFragmentServiceImpl implements IReagentPlasmidFragmentService{
	
	@Autowired
	private ReagentPlasmidFragmentMapper reagentPlasmidFragmentMapper;	

	@Override
	public ReagentPlasmidFragment insert(ReagentPlasmidFragment entity) {
		Integer insert = reagentPlasmidFragmentMapper.insert(entity);
		Assert.isTrue(insert==1, "添加失败");
		return entity;
	}
	
	@Override
	public boolean deleteById(Long id) {
		Integer b = reagentPlasmidFragmentMapper.deleteById(id);
		return b==1 ? true: false;
	}
	
	@Override
	public boolean updateById(ReagentPlasmidFragment entity) {
		entity.setUpdateTime(new Date());
		Integer b = reagentPlasmidFragmentMapper.updateById(entity);
		return b==1 ? true: false;
	}
	
	@Override
	public ReagentPlasmidFragment selectById(Long id) {
		return reagentPlasmidFragmentMapper.selectById(id);
	}

	@Override
	public List<ReagentPlasmidFragment> selectList(Long kitId, Long reagentId) {
		LambdaQueryWrapper<ReagentPlasmidFragment> wrapper = new LambdaQueryWrapper<>();
		wrapper.eq(ReagentPlasmidFragment::getKitId, kitId);
		wrapper.eq(ReagentPlasmidFragment::getReagentId, reagentId);
		return reagentPlasmidFragmentMapper.selectList(wrapper);
	}
}
